package stringbuilder;

/**
 * StringBuilder字符串拼接
 */

public class StringBuilderDemo1 {
    public static void main(String[] args) {
        // 获取当前开始时间
        long start = System.currentTimeMillis();

        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= 50000; i++) {
            sb.append(i);
        }
        System.out.println(sb);
        // 获取当前结束时间
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }

    // ctrl + alt + M 快速抽取方法
    private static void method() {
        long start = System.currentTimeMillis();
        String s = "";
        for (int i = 1; i <= 50000; i++) {
            s += i;
        }
        System.out.println(s);
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }
}
